package com.service.component.relation.controller;

import com.service.component.common.CommonResult;
import com.service.component.common.enumerate.OperateTypeEnum;
import com.service.component.log.aspect.SysOperateLog;
import com.service.component.relation.services.RelationServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：Calvin
 * @create ：2021/7/26 10:28
 * @description：中间关联表的管理
 * @modified By：
 * @version: 1.0.0$
 */
@Slf4j
@RestController
@Api(value = "中间关联表的管理")
@RequestMapping("/relation")
public class RelationController {

    @Autowired
    private RelationServices relationServices;

    @DeleteMapping("deleteUserPerm")
    @ApiOperation(value = "删除用户权限", notes = "删除用户权限")
    @SysOperateLog(descrption = "删除用户权限",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteUserPermByUserIdAndPermId(String userId, String PermId) {
        return relationServices.deleteUserPermByUserIdAndPermId(userId,PermId);
    }

    @DeleteMapping("deleteUserRole")
    @ApiOperation(value = "删除组角色", notes = "删除组角色")
    @SysOperateLog(descrption = "删除组角色",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteUserRoleByUserIdAndPermId(String userId, String roleId) {
        return relationServices.deleteUserRoleByUserIdAndPermId(userId,roleId);
    }

    @DeleteMapping("deleteUserGroup/{userId}/{groupId}")
    @ApiOperation(value = "删除用户组", notes = "删除用户组")
    @SysOperateLog(descrption = "删除用户组",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteUserGroupByUserIdAndPermId(@PathVariable String userId, @PathVariable String groupId) {
        return relationServices.deleteUserGroupByUserIdAndPermId(userId,groupId);
    }

    @DeleteMapping("deleteRolePerm/{roleId}/{permId}")
    @ApiOperation(value = "删除角色权限", notes = "删除角色权限")
    @SysOperateLog(descrption = "删除角色权限",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteRolePermByRoleIdAndPermId(@PathVariable String roleId, @PathVariable String permId) {
        return relationServices.deleteRolePermByRoleIdAndPermId(roleId,permId);
    }

    @DeleteMapping("deleteGroupPerm/{groupId}/{PermId}")
    @ApiOperation(value = "删除组权限", notes = "删除组权限")
    @SysOperateLog(descrption = "删除组权限",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteGroupPermByUserIdAndPermId(@PathVariable String groupId, @PathVariable String PermId) {
        return relationServices.deleteGroupPermByUserIdAndPermId(groupId,PermId);
    }

    @DeleteMapping("deleteGroupRole/{groupId}/{roleId}")
    @ApiOperation(value = "删除组角色", notes = "删除组角色")
    @SysOperateLog(descrption = "删除组角色",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteGroupRoleByUserIdAndPermId(@PathVariable String groupId, @PathVariable String roleId) {
        return relationServices.deleteGroupRoleByUserIdAndPermId(groupId,roleId);
    }


    @DeleteMapping("deleteUserFilterPerm/{userId}/{PermId}")
    @ApiOperation(value = "删除用户父权限", notes = "删除用户父权限")
    @SysOperateLog(descrption = "删除用户父权限",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteUserFilterPermByUserIdAndPermId(@PathVariable String userId, @PathVariable String PermId) {
       return relationServices.deleteUserFilterPermByUserIdAndPermId(userId,PermId);
    }

    @DeleteMapping("deleteUserFilterRole")
    @ApiOperation(value = "删除组父角色", notes = "删除组父角色")
    @SysOperateLog(descrption = "删除组父角色",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteUserFilterRoleByUserIdAndPermId(String userId, String roleId) {
        return relationServices.deleteUserFilterRoleByUserIdAndPermId(userId,roleId);
    }

    @DeleteMapping("deleteGroupFilterPerm/{groupId}/{PermId}")
    @ApiOperation(value = "删除组父权限", notes = "删除组父权限")
    @SysOperateLog(descrption = "删除组父权限",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteGroupFilterPermByUserIdAndPermId(@PathVariable String groupId, @PathVariable String PermId) {
        return relationServices.deleteGroupFilterPermByUserIdAndPermId(groupId,PermId);
    }

    @DeleteMapping("deleteGroupFilterRole/{groupId}/{roleId}")
    @ApiOperation(value = "删除组父角色", notes = "删除组父角色")
    @SysOperateLog(descrption = "删除组父角色",operateType = OperateTypeEnum.REMOVE)
    public CommonResult deleteGroupFilterRoleByUserIdAndPermId(@PathVariable String groupId, @PathVariable String roleId) {
        return relationServices.deleteGroupFilterRoleByUserIdAndPermId(groupId,roleId);
    }
}
